# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Aaron, phrakture, Griffin <aaron@archlinux.org>
# Contributor: Gustav Munkby <grddev@gmx.net>

pkgname=antiword
pkgver=0.37
pkgrel=9
pkgdesc="A free MS Word reader for Linux and RISC OS"
arch=('loong64' 'x86_64')
url="http://www.winfield.demon.nl/"
license=('GPL')
depends=('bash')
source=("http://www.winfield.demon.nl/linux/$pkgname-$pkgver.tar.gz"
        '10_fix_buffer_overflow_wordole_c.patch')
md5sums=('f868e2a269edcbc06bf77e89a55898d1'
         '3eb02e9d913b355d64d9a30b08fc390f')
sha256sums=('8e2c000fcbc6d641b0e6ff95e13c846da3ff31097801e86702124a206888f5ac'
            '9ffa1a21be3fd639fb5a779f2155735574dea75cee8d67228669cf18508235e1')

prepare() {
  cd "$srcdir/$pkgname-$pkgver"
  patch -p1 -i ../10_fix_buffer_overflow_wordole_c.patch
}

build() {
  cd "$srcdir/$pkgname-$pkgver"

  sed -i "s|GLOBAL_INSTALL_DIR =.*|GLOBAL_INSTALL_DIR = /usr/bin|g" Makefile.Linux
  make OPT="$CFLAGS -DNDEBUG" LDFLAGS="$LDFLAGS"
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  make DESTDIR="$pkgdir" global_install
  install -Dm644 Docs/antiword.1 "$pkgdir/usr/share/man/man1/antiword.1"
}
